home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group97a.txt / 000013_icon-group-sender _Tue Jan 7 14:01:06 1997.msg < prev    next >
Internet Message Format  |  2000-09-20  |  2KB

  1. Received: by cheltenham.cs.arizona.edu; Tue, 7 Jan 1997 14:36:15 MST
  2. Date: Tue, 7 Jan 1997 14:01:06 -0600
  3. Message-Id: <199701072001.OAA06901@ns1.computek.net>
  4. Mime-Version: 1.0
  5. Content-Type: text/plain
  6. Content-Transfer-Encoding: 7bit
  7. From: gep2@computek.net
  8. Subject: Another Question from the Neophyte -Reply
  9. To: icon-group@cs.arizona.edu
  10. X-Mailer: SPRY Mail Version: 04.00.06.17
  11. Errors-To: icon-group-errors@cs.arizona.edu
  12. Status: RO
  13. Content-Length: 1522
  14.  
  15. >The question was how best to scan for the last nonblank token,
  16. as I recall.  
  17.  
  18. Well, I don't recall the problem being described in QUITE that way... if so, one 
  19. probably needs to consider things like nesting and embedded (e.g. in quoted 
  20. strings) commas or spaces... forcing characters and all the other minutae.
  21.  
  22. >Using reverse() seems the most natural way to do it, if no
  23. preceding tokens are needed.  
  24.  
  25. It actually works quite well, even IF preceding tokens are needed.  You just get 
  26. them AFTER the "last" one, rather than before it.
  27.  
  28. >Otherwise, a normal left-to-right scan to put tokens on a list (tokenlist) 
  29. would be best.  
  30.  
  31. I tend to avoid that kind of thing since I think it's rather contrary to the 
  32. spirit of ICON... rather more the way you'd do things in C (which isn't 
  33. necessarily BAD per se, but it means you're thinking about things in the 
  34. old-fashioned knit-one-perl-two paradigms).
  35.  
  36. >    But I do wonder about the implementation of reverse().  If it is a
  37. very efficient operation, I'm sure it's the best general solution.  I am
  38. unfamiliar with the Icon source, so I do not know if it moves a lot of data
  39. around, or just resets some pointers and flags to give the appearance of
  40. reversing a string.  
  41.  
  42. It's a pretty safe guess that it actually creates an inverted copy of the 
  43. string.  This ought to be done efficiently enough (especially when compared to 
  44. the OTHER functions your Icon code calls up!) that one needn't worry a great 
  45. deal about it.
  46.  
  47. Gordon Peterson
  48. http://www.computek.net/public/gep2/
  49.